package com.example.rxpermissiondemo;

import android.app.Activity;
import android.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

/**
 * @author josan_tang
 * @date 11/27/17.
 */

public class DialogUtil {

    /**
     * 显示去设置页面的弹框
     * @param activity
     * @param content
     */
    public static void showGoSettingDialog(final Activity activity, String content) {
        View view = LayoutInflater.from(activity).inflate(R.layout.activity_dialog, null);
        TextView tvContent = view.findViewById(R.id.tv_content);
        TextView tvGoSetting = view.findViewById(R.id.tv_setting);
        TextView tvExit = view.findViewById(R.id.tv_exit);
        tvContent.setText(content);
        AlertDialog.Builder builder = new AlertDialog.Builder(activity)
                .setView(view)
                .setCancelable(false);
        final AlertDialog dialog = builder.create();
        dialog.show();
        tvGoSetting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                PermissionUtil.goAppDetailSetting(activity);
            }
        });
        tvExit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                activity.finish();
            }
        });
    }
}
